using UnityEngine;

namespace GameToolkit.BehaviourTree
{

    [System.Serializable]
    [CompositeTitle("创建寄存器")]
    [CompositeIcon("d49d838e485054640ade70ce991e3a5c")]
    [CompositeCategory]
    internal sealed class RegisterComposite : Composite
    {
        [SerializeField]
        string m_Title;

        [SerializeField, HideInInspector, JsonCloneable(false)]
        CompositeState m_Input;

        internal CompositeState Source
        {
            get => m_Input;
            set => m_Input = value;
        }

        public override BehaviourTreeObject Create()
        {
            return null;
        }

#if UNITY_EDITOR
        internal override void ResetGUID()
        {
            base.ResetGUID();
            m_Input.composite?.ResetGUID();
        }
#endif

        public override string GetDescription()
        {
            return string.IsNullOrEmpty(m_Title) ? "<Unnamed>" : m_Title;
        }

    }

    // 寄存器引用
    [System.Serializable]
    [CompositeTitle("寄存器")]
    [CompositeIcon("d49d838e485054640ade70ce991e3a5c")]
    [CompositeCategory]
    internal sealed class RegisterReference : Composite, IWithoutInspectorComposite
    {
        [SerializeReference]
        RegisterComposite m_Register;

        public RegisterComposite Register
        {
            get { return m_Register; }
            internal set
            {
                m_Register = value;
            }
        }

        public override string GetDescription()
        {
            return m_Register == null ? "<missing>" : m_Register.GetDescription();
        }

        public override BehaviourTreeObject Create()
        {
            return null;
        }
    }
}
